package com.yzt.sys.service.impl;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yzt.base.service.impl.BaseServiceImpl;
import com.yzt.sys.entity.RoleMenu;
import com.yzt.sys.mapper.RoleMenuMapper;
import com.yzt.sys.service.IRoleMenuService;

/**
 * <p>
 * 角色菜单关联表 服务实现类
 * </p>
 *
 * @author Y
 * @since 2020-12-21
 */
@Service
public class RoleMenuServiceImpl extends BaseServiceImpl<RoleMenuMapper, RoleMenu> implements IRoleMenuService {

	@Override
	public List<Long> getMenuIdList(Long roleId) {
		List<Long> list = this.listObjs(
				Wrappers.<RoleMenu>lambdaQuery().select(RoleMenu::getMenuId).eq(RoleMenu::getRoleId, roleId), a -> {
					return Long.valueOf(a.toString());
				});
		return list;
	}

	@Override
	public List<Long> getMenuIdList(List<Long> roleIds) {
		List<Long> list = this
				.listObjs(Wrappers.<RoleMenu>lambdaQuery().select(RoleMenu::getMenuId).in(RoleMenu::getRoleId, roleIds),
						a -> {
							return Long.valueOf(a.toString());
						})
				.stream().distinct().collect(Collectors.toList());
		return list;
	}

}
